{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys, os\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from statsmodels.tsa.base import tsa_model as tsa\n",
    "from statsmodels.tsa import holtwinters as hw\n",
    "\n",
    "from nyoka import ExponentialSmoothingToPMML \n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def import_data(trend=False, seasonality=False):\n",
    "    \"\"\"\n",
    "    Returns a dataframe with time series values.\n",
    "    :param trend: boolean\n",
    "        If True, returns data with trend\n",
    "    :param seasonality: boolean\n",
    "        If True, returns data with seasonality\n",
    "    :return: ts_data: DataFrame\n",
    "        Index of the data frame is either a time-index or an integer index. First column has time series values\n",
    "    \"\"\"\n",
    "    if trend and seasonality:\n",
    "        # no of international visitors in Australia\n",
    "        data = [41.7275, 24.0418, 32.3281, 37.3287, 46.2132, 29.3463, 36.4829, 42.9777, 48.9015, 31.1802, 37.7179,\n",
    "                40.4202, 51.2069, 31.8872, 40.9783, 43.7725, 55.5586, 33.8509, 42.0764, 45.6423, 59.7668, 35.1919,\n",
    "                44.3197, 47.9137]\n",
    "        index = pd.DatetimeIndex(start='2005', end='2010-Q4', freq='QS')\n",
    "        ts_data = pd.Series(data, index)\n",
    "        ts_data.index.name = 'datetime_index'\n",
    "        ts_data.name = 'n_visitors'\n",
    "        return ts_data\n",
    "    elif trend:\n",
    "        # no. of annual passengers of air carriers registered in Australia\n",
    "        data = [17.5534, 21.86, 23.8866, 26.9293, 26.8885, 28.8314, 30.0751, 30.9535, 30.1857, 31.5797, 32.5776,\n",
    "                33.4774, 39.0216, 41.3864, 41.5966]\n",
    "        index = pd.DatetimeIndex(start='1990', end='2005', freq='A')\n",
    "        ts_data = pd.Series(data, index)\n",
    "        ts_data.index.name = 'datetime_index'\n",
    "        ts_data.name = 'n_passengers'\n",
    "        return ts_data\n",
    "    elif seasonality:\n",
    "        pass\n",
    "    else:\n",
    "        # Oil production in Saudi Arabia\n",
    "        data = [446.6565, 454.4733, 455.663, 423.6322, 456.2713, 440.5881, 425.3325, 485.1494, 506.0482, 526.792,\n",
    "                514.2689, 494.211]\n",
    "        index = pd.DatetimeIndex(start='1996', end='2008', freq='A')\n",
    "        ts_data = pd.Series(data, index)\n",
    "        ts_data.index.name = 'datetime_index'\n",
    "        ts_data.name = 'oil_production'\n",
    "        return ts_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simple Exponential Smoothing\n",
    "# No Trend No Seasonality"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\nibo\\AppData\\Local\\Continuum\\anaconda3\\envs\\ZXPO\\lib\\site-packages\\ipykernel_launcher.py:36: FutureWarning: Creating a DatetimeIndex by passing range endpoints is deprecated.  Use `pandas.date_range` instead.\n"
     ]
    }
   ],
   "source": [
    "ts_data = import_data(trend=False, seasonality=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Yearly oil prodcution in Saudi Arabia"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\nibo\\AppData\\Local\\Continuum\\anaconda3\\envs\\ZXPO\\lib\\site-packages\\pandas\\plotting\\_converter.py:129: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.\n",
      "\n",
      "To register the converters:\n",
      "\t>>> from pandas.plotting import register_matplotlib_converters\n",
      "\t>>> register_matplotlib_converters()\n",
      "  warnings.warn(msg, FutureWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1998fcaf4e0>]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xl8VNX5+PHPk52sJBDCkkAS9n0L++JWRdFKUQGtCyrg2ta61K+2/dXaxVq1aq21VgEXUEFFKu47KgqEhH0nMAlhTchAQhKyn98fc6NRlmwzuTOT5/165ZWbM3fuPCcJDzdnznmOGGNQSinlvwLsDkAppZRnaaJXSik/p4leKaX8nCZ6pZTyc5rolVLKz2miV0opP6eJXiml/JwmeqWU8nOa6JVSys8F2R0AQPv27U1ycrLdYSillE/JzMw8YoyJr+88r0j0ycnJZGRk2B2GUkr5FBHJach5OnSjlFJ+ThO9Ukr5OU30Sinl5zTRK6WUn9NEr5RSfk4TvVJK+TlN9Eop5ec00SulvFZJeRWvrM6huLzK7lB8miZ6pZTXemDZFn63dDPTn13JocIyu8PxWZrolVJe6cPNB3kzcx8XDehITkEJU5/5hm0Hi+wOyydpoldKeZ28ojLuf2sTA7vE8NRVQ3njlrEYA9OeXclXO/PtDs/naKJXSnkVYwz3LtnIicpqnpgxhODAAPp1jmbp7WNJjG3DDS+uYfGavXaH6VM00SulvMorq/eyfEc+v53clx4dIr9r7xTThjduGcO4Hu35vyWbeOyjHRhjbIzUd2iiV0p5jT35xfz1vW1M7BXPtaO7nfR4VFgw82amcdXIJJ7+IotfL15PeVW1DZH6Fq8oU6yUUlXVNdz5+gZCggJ49IpBiMgpzwsODOChqQPpGhfB3z/czsFjZTx33XDahoe0cMS+Q+/olVJe4d9f7GZD7jEemjqQhOiwM54rItx6dnf+ddVQ1uce47L/fEtOQUkLRep7NNErpWy3IfcYT32+i6lDu3DxoE4Nft5PB3fmlT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Vhtc/H9YPIwFW++VugSlzlmm/F9UPtDGwE7m/poE9HRCKBJcCvjTFFZzr1FG3mDO22c0Pfaq/TCVgA3GB+WL/JNm7o223A+8aY3FM8bjs39C8ImADcA4wAUoHr3RxmkzS3byLSA+iLqzBkF1wFJSc2JRZN9KdhjNlujLnAGDMceA3rDs8YU2WMudMYM8QYMwVoC+wChliP7zauAbbXcY2x2c76T2gJ8Iox5i2r+XCdP+074RqugNNXH21QVdKW5qa+Ia43298Dfm/9+Ww7N/VtDPALcVWffQxXwcGHWyD8ernx93KdMWaPMaYK+B+u99ts5aa+TQVWWcNRxbjG8Uc3JR5N9KchIh2szwHA73EVcUNEwkUkwjo+H6gyxmwF9gP9RKR2bPd8frj1oi2s9wvmAduMMY/XeWgZUDtzZibwdp32U1Uf/Qi4QERirdkCF1httnFX30QkBFiKa5z0jRYK/4zc1TdjzNXGmK7GVX32Hlx9vK9lenF6bvy9XAPE1vl3dy6w1eMdOAM39m0vcJY1TBwMnEVTc0pT3sH1tw9cd+wHgUpc/7vOwrVH7k7r42G+X1yWDOywvuGfAt3qXOcWq30j8A7Qzgv6Nh7Xn7gbgfXWx2SgHa43lXdZn+Os8wX4N66/YDYBaXWudSOuqqRZuIY3/KJvwDXWz359nY8h/tC3H13zerxn1o07fy/Pt66zCXgRCPGHvuGaafNfK6dsBR5vaky6MlYppfycDt0opZSf00SvlFJ+ThO9Ukr5OU30Sinl5zTRK6WUn9NEr5RSfk4TvVJK+TlN9Eop5ef+P8jtmp1nOWW3AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(ts_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create a model object using statsmodels, for simple exponential smoothing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# trend: {add, mul, None}\n",
    "# seasonal: {add, mul, None}\n",
    "# damped: {True, False}\n",
    "# seasonal_periods: {int, None}\n",
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend=None, \n",
    "                                    damped=False, \n",
    "                                    seasonal=None, \n",
    "                                    seasonal_periods=None)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "results_obj.model.trend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([446.6565, 454.4733, 455.663 , 423.6322, 456.2713, 440.5881,\n",
       "       425.3325, 485.1494, 506.0482, 526.792 , 514.2689, 494.211 ])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_obj.model.endog"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime_index\n",
       "1996-12-31    446.6565\n",
       "1997-12-31    454.4733\n",
       "1998-12-31    455.6630\n",
       "1999-12-31    423.6322\n",
       "2000-12-31    456.2713\n",
       "2001-12-31    440.5881\n",
       "2002-12-31    425.3325\n",
       "2003-12-31    485.1494\n",
       "2004-12-31    506.0482\n",
       "2005-12-31    526.7920\n",
       "2006-12-31    514.2689\n",
       "2007-12-31    494.2110\n",
       "Freq: A-DEC, Name: oil_production, dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_obj.data.orig_endog"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create a pmml file from the model object using Nyoka and the exporter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Holt's Exponential Smoothing (only trend, no seasonality)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts_data = import_data(trend=True, seasonality=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(ts_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Additive trend. No damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=False, \n",
    "                                    seasonal=None, \n",
    "                                    seasonal_periods=None)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "initial_level, inital_slope, smoothing_level and smoothing_slope are the relavant parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Addditve trend with damping**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=True, \n",
    "                                    seasonal=None, \n",
    "                                    seasonal_periods=None)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Multiplicative trend. No damping**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='mul', \n",
    "                                    damped=False, \n",
    "                                    seasonal=None, \n",
    "                                    seasonal_periods=None)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Multiplicative trend with damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='mul', \n",
    "                                    damped=True, \n",
    "                                    seasonal=None, \n",
    "                                    seasonal_periods=None)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Holt - Winter Exponential Smoothing (trend and seasonality present)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Additive trend, additive seasonality, no damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ts_data = import_data(trend=True, seasonality=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(ts_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=False, \n",
    "                                    seasonal='add', \n",
    "                                    seasonal_periods=4)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Additive trend, additive seasonality, with damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=True, \n",
    "                                    seasonal='add', \n",
    "                                    seasonal_periods=4)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Additive trend, multiplicative seasonality, no damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=False, \n",
    "                                    seasonal='mul', \n",
    "                                    seasonal_periods=4)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** Additive trend, multiplicative seasonality with damping **"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_obj = hw.ExponentialSmoothing(ts_data, \n",
    "                                    trend='add', \n",
    "                                    damped=False, \n",
    "                                    seasonal='mul', \n",
    "                                    seasonal_periods=4)\n",
    "results_obj = model_obj.fit(optimized=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pmml_file_name = 'exponential_smoothing.pmml'\n",
    "ExponentialSmoothingToPMML(ts_data, model_obj, results_obj, pmml_file_name);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
